package cn.t.keycloak.demo.mfa.sms.spi.impl;

import cn.t.keycloak.demo.mfa.sms.spi.ISmsSenderProvider;
import cn.t.keycloak.demo.mfa.sms.spi.ISmsSpiProviderFactory;
import lombok.extern.slf4j.Slf4j;
import org.keycloak.Config;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;

/**
 * @author 陶敏麒
 * @date 2023/11/20 15:39
 */
@Slf4j
public class SmsSpiProviderFactoryImpl implements ISmsSpiProviderFactory {

    public static final String ID = "defaultSmsSpiProviderFactory";
    @Override
    public ISmsSenderProvider create(KeycloakSession keycloakSession) {
        return new SmsSenderProviderImpl(keycloakSession);
    }

    @Override
    public void init(Config.Scope scope) {
        log.info(">>>>开始加载默认的短信验证码发送端点SmsSpiProviderFactoryImpl");
    }

    @Override
    public void postInit(KeycloakSessionFactory keycloakSessionFactory) {

    }

    @Override
    public void close() {

    }

    @Override
    public String getId() {
        return ID;
    }
}
